home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Libraries & Documentation / Tutorial ƒ / Assignment4.p < prev    next >
Text File  |  1995-05-01  |  965b  |  50 lines

  1. program Assignment4;
  2.     uses
  3. {$ifc UNDEFINED THINK_PASCAL}
  4.         Types, QuickDraw, Menus, Windows, TextEdit, Fonts, Dialogs, Memory, OSEvents, {}
  5. {$endc}
  6.         SAT;
  7.  
  8.     var
  9.         ignore: SpritePtr;
  10.  
  11.     var
  12.         direction: Integer;
  13.  
  14.     procedure HandleSprite (me: SpritePtr);
  15.     begin
  16.         me^.position.h := me^.position.h + direction;
  17.         if me^.position.h <= 0 then
  18.             direction := 1;
  19.         if me^.position.h >= 200 then
  20.             direction := -1;
  21.     end; {HandleSprite}
  22.  
  23.     procedure SetupSprite (me: SpritePtr);
  24.     begin
  25.         me^.task := @HandleSprite;
  26.         me^.face := SATGetFace(128);
  27.         direction := 1;
  28.     end; {SetupSprite}
  29.  
  30.     const
  31.         kTicksPerFrame = 2;
  32.     var
  33.         t: Longint;
  34.  
  35. begin
  36. {If we don't use Think Pascal, we must make standard inits ourselves.}
  37. {$ifc UNDEFINED THINK_PASCAL}
  38.     SATInitToolbox;
  39. {$endc}
  40.  
  41.     SATInit(128, 129, 478, 302);
  42.     ignore := SATNewSprite(0, 200, 200, @SetupSprite);
  43.     while not Button do
  44.         begin
  45.             t := TickCount;
  46.             SATRun(true);
  47.             while TickCount < t + kTicksPerFrame do
  48.                 ;
  49.         end;
  50. end.